package com.sansan.qiangji.service.impl.device;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sansan.qiangji.entity.device.BeltParam;
import com.sansan.qiangji.form.device.beltParam.BeltParamListForm;
import com.sansan.qiangji.mapper.device.BeltParamMapper;
import com.sansan.qiangji.service.inter.device.BeltParamService;
import com.sansan.qiangji.utils.pageUtils.PageResult;
import com.sansan.qiangji.utils.pageUtils.PageUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BeltParamServiceImpl implements BeltParamService {
    private BeltParamMapper beltParamMapper;

    @Resource
    public void setBeltParamMapper(BeltParamMapper beltParamMapper) {
        this.beltParamMapper = beltParamMapper;
    }

    @Override
    public PageResult<BeltParam> beltParamList(BeltParamListForm beltParamListForm) {
        int pageNum = beltParamListForm.getPageNum();
        int pageSize = beltParamListForm.getPageSize();
        PageHelper.startPage(pageNum, pageSize);
        BeltParam beltParam = new BeltParam();
        beltParam.setBeltParamName(beltParamListForm.getBeltParamName());
        beltParam.setBeltParamAddress(beltParamListForm.getBeltParamAddress());
        List<BeltParam> beltParams = beltParamMapper.beltParamList(beltParam);
        return PageUtil.getPageResult(new PageInfo<>(beltParams));
    }

    @Override
    public List<BeltParam> findAll() {
        return beltParamMapper.findAll();
    }

    @Override
    public BeltParam findById(Integer beltParamId) {
        return beltParamMapper.findById(beltParamId);
    }

    @Override
    public List<BeltParam> findBeltParamName(String beltParamName) {
        return beltParamMapper.findBeltParamName(beltParamName);
    }

    @Override
    public int addBeltParam(BeltParam beltParam) {
        return beltParamMapper.addBeltParam(beltParam);
    }

    @Override
    public int updateBeltParam(BeltParam beltParam) {
        return beltParamMapper.updateBeltParam(beltParam);
    }

    @Override
    public int deleteById(Integer beltParamId) {
        return beltParamMapper.deleteById(beltParamId);
    }
}
